package com.zh.stargraph2.core.service.impl;

import com.zh.stargraph2.core.pojo.ComfyuiModel;
import com.zh.stargraph2.core.service.FreemarkerService;
import freemarker.template.Configuration;
import freemarker.template.Template;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.StringWriter;
import java.util.Map;

@Service
public class FreemarkerServiceImpl implements FreemarkerService {

    @Autowired
    Configuration configuration;

    @Override
    public String renderText2Image(ComfyuiModel model) throws Exception {
        Template template = configuration.getTemplate("t2i.ftlh");
        StringWriter temp = new StringWriter();
        template.process(Map.of("config", model), temp);
        return temp.toString();
    }
}
